package com.huike.clues.service.impl;

import com.huike.clues.domain.SysDictType;
import com.huike.clues.mapper.SysDictTypeMapper;
import com.huike.clues.service.ISysDictTypeService;
import com.huike.common.constant.UserConstants;
import com.huike.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService {
    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    /**
     * 分页查询数据字典类型信息
     */
    @Override
    public List<SysDictType> selectDictTypeList(SysDictType dictType) {
        return sysDictTypeMapper.selectDictTypeList(dictType);
    }
    /**
     * 查询字典类型详细信息
     */
    @Override
    public SysDictType selectDictTypeById(Long dictId) {
        return sysDictTypeMapper.selectDictTypeById(dictId);
    }

    @Override
    public String checkDictTypeUnique(SysDictType dict) {
        Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
        SysDictType dictType = sysDictTypeMapper.checkDictTypeUnique(dict.getDictType());
        if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;


    }

    /**
     * 新增字典类型信息
     */
    @Override
    public void insertDictType(SysDictType dict) {
        sysDictTypeMapper.insertDictType(dict);
    }
    /**
     * 修改字典类型
     */
    @Override
    public void updateDictType(SysDictType dict) {
        sysDictTypeMapper.updateDictType(dict);
    }

    /**
     * 删除字典类型
     */
    @Override
    public void deleteDictTypeByIds(Long[] dictIds) {
        sysDictTypeMapper.deleteDictTypeByIds(dictIds);
    }


}
